﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace myBoard.App.Model
{
    public class SingletonFactory
    {
        // Fields
        private static Dictionary<string, object> Instances = new Dictionary<string, object>();

        // Methods
        public static T GetInstance<T>() where T : class
        {
            T local;
            try
            {
                Type type = typeof(T);
                string fullName = type.FullName;
                if (Instances.ContainsKey(fullName))
                {
                    return (Instances[fullName] as T);
                }
                object obj2 = Activator.CreateInstance(type);
                Instances[fullName] = obj2;
                local = obj2 as T;
            }
            catch (Exception exception)
            {
                throw new Exception(exception.Message);
            }
            return local;
        }
    }
}
